﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management.Automation;

namespace SimpleNotify.Powershell
{
    /// <summary>
    /// This is our "Get-Subscriber" custom PowerShell
    /// cmdlet.
    /// </summary>
    [Cmdlet(VerbsCommon.Get, "Subscriber", SupportsShouldProcess = false)]
    public class GetSubscriberCmdlet : Cmdlet
    {
        private Implementation _implementation = new Implementation();

        private string _server;

        [Parameter(Mandatory = true, HelpMessage = "Hostname of the Server which runs the Notify Service")]
        public string Server
        {
            get { return _server; }
            set { _server = value; }
        }

        /// <summary>
        /// This is our main processing method, called
        /// once for each input record in the pipeline
        /// </summary>
        protected override void ProcessRecord()
        {
            List<string> subscriber = _implementation.GetSubscriber(_server).ToList();
            WriteObject(subscriber, true);
        }
    }
}
